#include "mainwindow.h"
#include "webgraph.h"

#include <QMdiArea>
#include <QTime>

static void addItem(WebGraph* graph, const QString& type, const QString& name, int max)
{
    QList<double> data;
    for (int d = 0; d < 10; d++)
        data.append(qrand() % max);
    graph->addItem(type, name, data);
}

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    m_mdiArea = new QMdiArea(this);
    setCentralWidget(m_mdiArea);

    m_graph1 = new WebGraph(this);
    m_graph1->setTitle("Web Graph #1");
    m_graph1->setTitleColor(Qt::blue);
    m_graph2 = new WebGraph(this);
    m_graph2->setTitle("Web Graph #2");
    m_graph2->setTitleColor(Qt::red);

    m_mdiArea->addSubWindow(m_graph1);
    m_mdiArea->addSubWindow(m_graph2);

    qsrand(QTime::currentTime().msec());
    addItem(m_graph1, "line", "Line #1", 100);
    addItem(m_graph1, "spline", "Spline #1", 100);
//    addItem(m_graph1, "spline", "Spline #2");
//    addItem(m_graph1, "line", "Line #2");

    addItem(m_graph2, "line", "Line #3", 1000);
    addItem(m_graph2, "spline", "Spline #3", 1000);
//    addItem(m_graph2, "spline", "Spline");
//    addItem(m_graph2, "pie", "Bar");

    m_graph1->render();
    m_graph2->render();
}
